home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-01-22 | 2.9 KB | 102 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // Special Effects.c
- ///--------------------------------------------------------------------------------------
-
- #include "Special Effects.h"
- #include "Timer.h"
-
- #define kWipeSpeed 1 // Number of microseconds between each line of the wipe
-
-
- ///--------------------------------------------------------------------------------------
- // WipeWindow
- ///--------------------------------------------------------------------------------------
-
- void WipeWindow(SpriteWorldPtr spriteWorldP)
- {
- short topRow, bottomRow;
- Rect sourceRect, destRect;
- GrafPtr savePort;
-
- GetPort(&savePort);
- SWSetPortToWindow(spriteWorldP);
-
- // Position topRow and bottomRow in the middle of the screen
- bottomRow = spriteWorldP->windRect.bottom - spriteWorldP->windRect.top;
- for (topRow = 0; topRow <= bottomRow; topRow++, bottomRow--)
- NULL;
-
- sourceRect.left = spriteWorldP->visScrollRect.left;
- sourceRect.right = spriteWorldP->visScrollRect.right;
- destRect.left = sourceRect.left + spriteWorldP->windRect.left;
- destRect.right = sourceRect.right + spriteWorldP->windRect.left;
-
- while (topRow >= 0)
- {
- StartMicrosecTimer();
-
- topRow--;
- bottomRow++;
-
- sourceRect.top = topRow;
- sourceRect.bottom = topRow+1;
- destRect.top = topRow + spriteWorldP->windRect.top;
- destRect.bottom = destRect.top+1;
-
- (*spriteWorldP->screenDrawProc)(spriteWorldP->workFrameP,
- spriteWorldP->windowFrameP, &sourceRect, &destRect);
-
- sourceRect.top = bottomRow;
- sourceRect.bottom = bottomRow+1;
- destRect.top = bottomRow + spriteWorldP->windRect.top;
- destRect.bottom = destRect.top+1;
-
- (*spriteWorldP->screenDrawProc)(spriteWorldP->workFrameP,
- spriteWorldP->windowFrameP, &sourceRect, &destRect);
-
- WaitMicroseconds(kWipeSpeed);
- }
-
- SetPort(savePort);
- }
-
-
- UnsignedWide lastMicroseconds, // Value of previous Microseconds() call
- curMicroseconds; // Value of current Microseconds() call
- unsigned long millisecDifference; // Difference between the two values
-
-
- ///--------------------------------------------------------------------------------------
- // StartMicrosecTimer - call this, then WaitMicroseconds
- ///--------------------------------------------------------------------------------------
-
- void StartMicrosecTimer( void )
- {
- Microseconds(&lastMicroseconds);
- }
-
-
- ///--------------------------------------------------------------------------------------
- // WaitMicroseconds
- ///--------------------------------------------------------------------------------------
-
- void WaitMicroseconds(unsigned long delay)
- {
- do
- {
- Microseconds(&curMicroseconds);
-
- // Has hi long has rolled over?
- if (curMicroseconds.hi > lastMicroseconds.hi)
- {
- millisecDifference =
- (0xffffffff - (lastMicroseconds.lo - curMicroseconds.lo))/1000;
- }
- else
- {
- millisecDifference = (curMicroseconds.lo - lastMicroseconds.lo)/1000;
- }
- } while (millisecDifference < delay);
- }
-
-